<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>逻辑与和逻辑或的用法</title>
  <script>
    let name;
    //表示的就是满足条件之后执行后面的代码，如果name没有定义或者为null，就将name设置为Ada
    !name&&(name='Ada');
    // alert(name)
    // isLogin()&&alert('登录成功')

    //逻辑或的用法
    let t;
    let b = 'test';
    let a = t||b||'helllo'; 
    // alert(a)  

    const errorCode = {
      404: '未找到页面',
      500: '服务器错误',
      default: '未知错误'
    };
    const res = { data: { msg: '数据库异常' } };
    let code = 501;
    let msg = errorCode[code] || res.data.msg || errorCode['default'];
    console.log(msg); // '未找到页面'
  </script>
</head>
<body>
  
</body>
</html>